package com.path.planning.entity.path;

import com.alibaba.fastjson.JSONObject;

import com.path.planning.util.path.GeoUtils;
import com.path.planning.util.path.entity.CustomEdge;
import com.path.planning.util.path.entity.NavigationConstants;
import com.path.planning.util.path.entity.PathTopologyData;
import org.locationtech.jts.algorithm.Angle;

/**
 * 规划结果之方案路径详细信息
 */
public class NavigationDetailInfoVo {
    /**
     * 分段路径名称
     */
    private String pathName;
    /**
     * 分段路径长度
     */
    private Double length;
    /**
     * 限速
     */
    private Double speed;
    /**
     * 转向标识
     */
    private Long azimuth;
    /**
     * 分段路径经纬度信息
     */
    private JSONObject geomJson;
    /**
     * 路径类型
     */
    private NavigationConstants.PathTypeEnum pathType;
    /**
     * 公路类型：只有pathType=road时，才有值
     */
    private NavigationConstants.RoadTypeEnum roadType;

    public NavigationDetailInfoVo() {
    }

    /**
     * @param edge      路径原始信息
     * @param isReverse 是否需要逆向赋值
     */
    public NavigationDetailInfoVo(CustomEdge edge, boolean isReverse) {
        PathTopologyData data = edge.getPathTopologyData();
        this.pathName = data.getPathName();
        this.length = data.getLength();
        this.speed = data.getSpeed();
        this.pathType = edge.getEdgeType();
        this.roadType = edge.getRoadTypeEnum();
        this.azimuth = Math.round(Math.toDegrees(Angle.angle(data.getLineGeometry().getStartPoint().getCoordinate(), data.getLineGeometry().getEndPoint().getCoordinate())) / 90);
        this.azimuth = this.azimuth < 0 ? Math.abs(this.azimuth) + 2 : this.azimuth;
        this.geomJson = JSONObject.parseObject(GeoUtils.getGeoJsonStrFromGeometry(isReverse ? data.getReverseMulLineGeometry() : data.getMulLineGeometry()));
    }

    public NavigationConstants.PathTypeEnum getPathType() {
        return pathType;
    }

    public void setPathType(NavigationConstants.PathTypeEnum pathType) {
        this.pathType = pathType;
    }

    public NavigationConstants.RoadTypeEnum getRoadType() {
        return roadType;
    }

    public void setRoadType(NavigationConstants.RoadTypeEnum roadType) {
        this.roadType = roadType;
    }

    public Double getSpeed() {
        return speed;
    }

    public void setSpeed(Double speed) {
        this.speed = speed;
    }

    public String getPathName() {
        return pathName;
    }

    public void setPathName(String pathName) {
        this.pathName = pathName;
    }

    public Double getLength() {
        return length;
    }

    public void setLength(Double length) {
        this.length = length;
    }

    public Long getAzimuth() {
        return azimuth;
    }

    public void setAzimuth(Long azimuth) {
        this.azimuth = azimuth;
    }

    public JSONObject getGeomJson() {
        return geomJson;
    }

    public void setGeomJson(JSONObject geomJson) {
        this.geomJson = geomJson;
    }
}
